<!doctype html>
<html lang="en">

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>Bitter Mobile Template</title>
		<link rel="stylesheet" href="assets/css/style.css">
		<meta name="viewport" content="initial-scale=1, maximum-scale=1, width=device-width">
		<meta name="description" content="Bitter Mobile Template">
		<meta name="keywords" content="bootstrap, mobile template, cordova, phonegap, mobile, html, responsive" />
	</head>

	<body>

		<!-- Page loading -->
		<div class="loading">
			<div class="spinner-grow"></div>
		</div>
		<!-- * Page loading -->

		<!-- App Header -->
		<div class="appHeader">
			<div class="pageTitle">登录</div>
			<div class="right">
				<a href="people-register.html" class="link">注册</a>
			</div>
		</div>
		<!-- * App Header -->

		<!-- App Capsule -->
		<div id="appCapsule">

			<div class="appContent">


				<div class="sectionTitle text-center mt-3">
					<div class="title">
						<h1>欢迎回来</h1>
					</div>
					<div class="lead mb-2">请输入账号密码</div>
				</div>

				<form action="index.html">
					<div class="form-group">
						<input type="text" class="form-control" id="phone" placeholder="手机号码">
					</div>
					<div class="form-group">
						<input type="password" class="form-control" id="pwd" placeholder="密码">
					</div>
					<div class="form-group row mt-3 mb-3">
						<div class="col-6">
							<div class="custom-control custom-checkbox">
								<input type="checkbox" class="custom-control-input" id="remember" />
								<label class="custom-control-label text-muted" for="remember">记住密码</label>
							</div>
						</div>
						<div class="col-6 text-right">
							<a href="people-forgot-password.html" class="text-muted">忘记密码?</a>
						</div>
					</div>
					<div>
						<button type="button" class="btn btn-primary btn-lg btn-block" href="javascript:void(0)" onclick="login()">
							登录
						</button>
						<script>
							function login() {  //成功进入homepage,手机号错误则显示未注册
								//普通类型传递
								var PostStringToRear = function(url_suffix, raw_data, success_function) {
											let jqxhr = $.post('http://47.95.220.161:8080'+url_suffix, raw_data, success_function).fail(function (xhr, status) {
													console.log('连接失败: ' + xhr.status + ', 原因: ' + status);
												});
											return jqxhr;
								}
								let first_url='/users/signinStatus';
								let first_data={
									"phone":document.getElementById('phone').value
								};
								let first_success= function(data) 
								{
									if(jQuery.isEmptyObject(data)){
										alert("手机号未注册");
										window.location.href = "people-login.html"; 
										return;
									}
									else{
										let search_url_suffix = '/users/loginUsers';
										let search_data = {
											"userNo":document.getElementById('phone').value,
											"password":document.getElementById('pwd').value
										};
										let search_success = function(data) {
											window.location.href = "homepage.html"; 
											console.log('成功, 收到的数据: ' + JSON.stringify(data));
										};
											PostStringToRear(search_url_suffix, search_data, search_success);
									}
								};
								PostStringToRear(first_url, first_data, first_success);
								
								};                   
                        </script>
					</div>
				</form>
				<div class="divider mt-3 mb-3"></div>

				<div class="text-muted text-center mb-2">其他方式登录</div>
				<div class="row">
					<div class="col-6">
						<button type="button" class="btn btn-facebook btn-block">
							<i class="icon ion-logo-facebook"></i>
							Facebook
						</button>
					</div>
					<div class="col-6">
						<button type="button" class="btn btn-twitter btn-block">
							<i class="icon ion-logo-twitter"></i>
							Twitter
						</button>
					</div>
				</div>


			</div>


		</div>
		<!-- appCapsule -->

		<!-- ///////////// Js Files ////////////////////  -->
		<!-- Jquery -->
		<script src="assets/js/lib/jquery-3.4.1.min.js"></script>
		<!-- Bootstrap-->
		<script src="assets/js/lib/popper.min.js"></script>
		<script src="assets/js/lib/bootstrap.min.js"></script>
		<!-- Owl Carousel -->
		<script src="assets/js/plugins/owl.carousel.min.js"></script>
		<!-- Main Js File -->
		<script src="assets/js/app.js"></script>
		<!-- <script src="login.js"></script> -->

	</body>

</html>
